package org.swxjava.assembler.avm1;

import org.swxjava.assembler.Constants;
import org.swxjava.assembler.ObjectCompiler;
import org.swxjava.util.Log;
import org.swxjava.util.LogFactory;
import org.swxjava.util.StringUtils;

public class AsInt implements ObjectCompiler {

	/** Logger */
	private static final Log LOG = LogFactory.getLog(AsInt.class);

	/** value */
	private Integer value = 0;

	public AsInt(Integer value) {
		this.value = value;
	}

	public int getByteSize() {
		return toString().length() / 2;
	}

	public byte[] toBytecode() {
		// TODO Auto-generated method stub
		return null;
	}

	public String toString() {
		return integerToBytecode(value);
	}

	public static String integerToBytecode(int integer) {
		String bytecode = Constants.DATA_TYPE_INTEGER
				+ StringUtils.getIntAsHex(integer, 4);
		return bytecode;
	}
}
